<?php
/**
 * SimplifyPHP Framework
 *
 * This file is part of SimplifyPHP Framework.
 *
 * SimplifyPHP Framework is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * SimplifyPHP Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Rodrigo Rutkoski Rodrigues, <rutkoski@gmail.com>
 */

require_once(dirname(__file__).'/IDictionary.php');
require_once(dirname(__file__).'/filter/IFilter.php');
require_once(dirname(__file__).'/validation/IValidator.php');

/**
 * Adds data filtering and validation to IDictionary.
 *
 * @author Rodrigo Rutkoski Rodrigues, <rutkoski@gmail.com>
 * @package Simplify_Kernel_Data
 */
interface IDataHolder extends IDictionary
{

  /**
   * Set a filter for a given key. * can be used as the key to set a global filter.
   *
   * @param $name string The key.
   * @param $filter IFilter The filter or null to clear.
   * @return void
   */
  public function setFilter($name, IFilter $filter = null);

  /**
   * Set a validation rule for a given key.
   *
   * @param $name string The key.
   * @param $rule IValidator The validator or null to clear.
   * @return void
   */
  public function setRule($name, IValidator $rule = null);

  /**
   * Validates the value of a given key. Clear all validation errors and set's new
   * errors if validation fails.
   *
   * @param $name string The key.
   * @throws IValidationException Thrown if validation fails.
   * @return void
   */
  public function validate($name);

  /**
   * Validates all data. Clear all validation errors and set's new errors if
   * validation fails.
   *
   * @throws IValidationException Thrown if validation fails.
   * @return void
   */
  public function validateAll();

  /**
   * Get validation errors.
   *
   * @return array Error messages.
   */
  public function getErrors();

}

?>